/* This code is inspired from a developement of Nikola Malovic
 * check http://blog.vuscode.com/malovicn/archive/2007/10/25/model-view-presenter-mvp-design-pattern-close-look-part-1-passive-view.aspx for more information
*/

#region
using Microsoft.SharePoint;
using System.Web.UI;
using System;
#endregion

namespace SharePointOfView.Patterns.MVP
{
    public class ViewBaseControl<TPresenter> : UserControl where TPresenter : IPresenter, new()
    {
        private TPresenter _presenter;

        public ViewBaseControl()
        {
            Presenter = new TPresenter();
        }

        public TPresenter Presenter
        {
            get { return _presenter; }
            set
            {
                _presenter = value;
                _presenter.View = this;
                _presenter.SPContext = SPContext.Current;
            }
        }
    }
}